/*
 * Copyright 2013 Aliyun.com All right reserved. This software is the
 * confidential and proprietary information of Aliyun.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Aliyun.com .
 */
package com.mtauto.action.device;

import java.util.Collection;

import org.codeanywhere.easyRestful.base.RequestContext;
import org.codeanywhere.easyRestful.base.annotation.Request;
import org.codeanywhere.easyRestful.base.annotation.SpringBean;

import com.mtauto.model.Device;
import com.mtauto.service.DeviceService;

/**
 * @author <a href="mailto:li.jinl@alibaba-inc.com">Stone.J</a> Nov 19, 2013
 */
public class List {

    @Request
    private RequestContext rc;
    @SpringBean
    private DeviceService  deviceService;

    public void execute() {
        boolean force = "true".equals(rc.getHttpServletRequest().getParameter("force"));
        Collection<Device> devices = deviceService.getDevices(force);
        rc.put("devices", devices);
    }

}
